<?php
/**
 * 头部菜单
 * User: adophper <hello@adophper.com>
 * Date: 2018/3/22
 * Time: 11:43
 */
namespace frontend\widgets;
use common\services\AdServices;
use yii\bootstrap\Widget;

class Ad extends Widget {

    private $view = '@frontend/views/widget/ad.php';

    public $position; //接收的参数信息

    public $params = [];

    public function init()
    {
        $adService = new AdServices();
        $content = $adService->getAdByPosition($this->position);
        $this->params['data'] = $content;
    }

    public function run()
    {
        echo $this->renderFile($this->view, $this->params);
    }
}